<?php

namespace app\common\service\lib;


use app\common\service\lib\kdzs\KdzsClient;
use app\common\service\lib\kdzs\KdzsLogisticsTraceMapGetRequest;

class ExpressLocusFree
{
    protected $kdzsClient;
    protected $req;

    /**
     * ExpressLocusFree constructor.
     * 初始化
     */
    public function __construct()
    {
        $this->kdzsClient = new KdzsClient($appkey=config('setting.kdzs.appkey'),
            $appSecret=config('setting.kdzs.appSecret'));
        $this->req = new KdzsLogisticsTraceMapGetRequest();

    }

    /**
     * Author:Yingbo Sun
     * 获取参数
     * @param $cpCode string 快递公司缩写
     * @param $mailNo string 快递单号
     * @param $origin string 发货地址
     * @param $destination string 用户省市区
     * @param $receiveAddress string 用户详细地址
     * @return kdzs\ResultSet|mixed
     * @throws \Exception
     */
    public function query($cpCode,$mailNo,$origin,$destination,$receiveAddress)
    {
        //快递公司 缩写
        $this->req->setCpCode($cpCode);
        //快递单号
        $this->req->setMailNo($mailNo);
        //宝贝地址
        $this->req->setOrigin('福建省漳州市');
        //用户地址
        $this->req->setDestination('上海市奉贤区');
        //用户详细地址
        $this->req->setReceiveAddress('上海市奉贤区五四公路3389号');
        $resp = $this->kdzsClient->execute($this->req);
        return $resp;
    }


}